<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>消防安全知识答题 - 问题5</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <header>
            <h1>消防安全知识答题</h1>
            <p>问题 5/6</p>
        </header>
        
        <div class="quiz-container">
            <div class="question">
                <h3>以下哪种情况下，不应该自行扑救初期火灾？</h3>
                <ul class="options">
                    <li class="option" onclick="checkAnswer(0)">火势较小且有合适的灭火器</li>
                    <li class="option" onclick="checkAnswer(1)">火灾刚刚开始且明确知道着火物质</li>
                    <li class="option" onclick="checkAnswer(2)">火势已经蔓延到天花板</li>
                    <li class="option" onclick="checkAnswer(3)">着火点在可以安全接近的位置</li>
                </ul>
                <div id="feedback" class="feedback"></div>
            </div>
        </div>
        
        <div id="certificate-container" class="success-container" style="display: none;">
            <h2>恭喜您！打卡成功</h2>
            <div class="certificate" id="certificate">
                <div class="certificate-content">
                    <h3>消防安全知识</h3>
                    <h2>打卡证书</h2>
                    <p>恭喜您已完成消防安全知识学习</p>
                    <p>问题：以下哪种情况下，不应该自行扑救初期火灾？</p>
                    <p>正确答案：火势已经蔓延到天花板</p>
                    <p class="date">日期: <span class="current-date"></span></p>
                </div>
            </div>
            <button class="btn download-btn">下载打卡证书</button>
            <a href="question6.html" class="btn next-btn">下一题</a>
        </div>
    </div>
    
    <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
    <script src="common.js"></script>
    <script>
        const correctAnswer = 2; // 正确答案索引
        
        function checkAnswer(selectedIndex) {
            const options = document.querySelectorAll('.option');
            const feedback = document.getElementById('feedback');
            const certificateContainer = document.getElementById('certificate-container');
            
            // 移除之前的选择
            options.forEach(option => {
                option.classList.remove('selected', 'correct', 'wrong');
            });
            
            // 添加选中样式
            options[selectedIndex].classList.add('selected');
            
            // 显示正确答案
            options[correctAnswer].classList.add('correct');
            
            if (selectedIndex === correctAnswer) {
                // 答对了
                feedback.textContent = '回答正确！当火势已经蔓延到天花板时，说明火势已经较大，应立即撤离并报警，不应自行扑救。';
                feedback.className = 'feedback correct';
                feedback.style.display = 'block';
                
                // 显示证书
                setTimeout(() => {
                    certificateContainer.style.display = 'block';
                }, 1500);
            } else {
                // 答错了
                options[selectedIndex].classList.add('wrong');
                feedback.textContent = '回答错误。当火势已经蔓延到天花板时，说明火势已经较大，应立即撤离并报警，不应自行扑救。请重新选择。';
                feedback.className = 'feedback wrong';
                feedback.style.display = 'block';
            }
        }
    </script>
</body>
</html>